<template>
  <div class="ant-list ant-list-split">
    <ul class="ant-list-items">
      <li class="ant-list-item" v-for="item in arr" :key="item.name">
        <div class="ant-list-item-meta">
          <div class="ant-list-item-meta-content">
            <h4 class="ant-list-item-meta-title">{{ item.title }}</h4>
            <div class="ant-list-item-meta-description">{{ item.description }}</div>
          </div>
        </div>
        <div class="ant-list-item-action">
          <el-switch v-model="emailForm[item.name]" />
        </div>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'

const arr = [
  {
    name: 'sysadmin',
    title: '接收系统通知',
    description: '系统通知、系统公告',
    value: true,
  },
  {
    name: 'todo',
    title: '接收待办消息',
    description: '所有来自待办中心的消息提醒（此邮件能让员工离线时不漏掉重要工作）',
    value: true,
  },
  {
    name: 'work',
    title: '接收工作通知',
    description: '所有来自工作通知的消息，包含各类工作任务、项目等来自工作计划等通知',
    value: true,
  },
]

const emailForm = reactive<{
  [key: string]: boolean
}>({})
</script>

<style lang="less" scoped>
.ant-list {
  width: 100%;
}

.ant-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  color: rgba(0, 0, 0, 0.85);
}

.ant-list-split .ant-list-item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* .ant-list-split .ant-list-item:last-child {
  border-bottom: none;
} */

.ant-list-item-meta {
  display: flex;
  flex: 1 1;
  align-items: flex-start;
  max-width: 100%;
}

.ant-list-item-meta-content {
  flex: 1 0;
  width: 0;
  color: rgba(0, 0, 0, 0.85);
}

.ant-list-item-action {
  flex: 0 0 auto;
  margin-left: 48px;
  padding: 0;
  font-size: 0;
  list-style: none;
}

.ant-list-item-meta-title {
  margin-bottom: 4px;
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  line-height: 1.5715;
}

.ant-list-item-meta-description {
  color: rgba(0, 0, 0, 0.45);
  font-size: 14px;
  line-height: 1.5715;
}
</style>
